include <fitFunction.scad>

// fragment(polygons) per cylinder
$fn = 180;

//parameters
bearingRadius = 17.5;
wallThickness = 2;

difference()
{
	union()
	{
		// main body
		cylinder(r = bearingRadius + wallThickness, h = 11.5);

		// tabs to hold bolts
		for(angle = [0 : 90 : 360])
		{
			rotate(angle + 45,[0,0,1])
			translate([bearingRadius+1.5, -3.5, 0])
			cube([wallThickness+wallThickness*2+3.5,7,wallThickness+2]);

		}
	}

	// bearing itself
	translate([0,0,-0.01])
	cylinder(r = fit(bearingRadius), h = 10.5);

	// hole for shaft
	cylinder(r = bearingRadius - 1, h = 50, center=true);

	// bolt holes
	for(angle = [0 : 90 : 360])
	{
		rotate(angle + 45,[0,0,1])
		translate([25.5, 0, 0])
		cylinder(r = fit(1.5), h = 50, center=true);
	}
}